.PHONY: install install-r  pub pub-r pub-p pkg pkg-r pkgd pkgd-r clean


nproc := $(shell nproc)
core := $(shell echo "$(nproc)-2" | bc)

argv :=$(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))


catkin_command:= catkin build 
# catkin_command:= catkin build 

pub_echo:= @echo "... \033[33m 正在打包 $(ver_chip)_v$(ver_robot) ... \033[0m "



install: pre
	$(catkin_command)

install-r: pre
	$(catkin_command) --cmake-args -DCMAKE_BUILD_TYPE=Release

pre:
	@catkin config --install

pub: install
	$(pub_echo)

pub-r: install-r
	$(pub_echo)


pub-p: 
	$(pub_echo)

pkg: pre
	$(catkin_command) --no-deps $(argv)

pkg-r: pre
	$(catkin_command) --no-deps $(argv) --cmake-args -DCMAKE_BUILD_TYPE=Release 

pkgd: pre
	$(catkin_command) $(argv)

pkgd-r: pre
	$(catkin_command) $(argv) -DCMAKE_BUILD_TYPE=Release

clean:
	rm -rf publish install devel logs build src/CMakeLists.txt .catkin_workspace .catkin_tools

help:
	@echo "命令如下："
	@echo "	make           	  说明：编译安装debug版,这个所有库都编译       示例：make"
	@echo "	make install   	  说明：编译安装debug版和make命令一样         示例：make"
	@echo "	make install-r 	  说明：编译安装release版,这个所有库都编译     示例：make install-r"
	@echo "	make pub       	  说明：打包debug版,这个所有库都编译           示例：make pub"
	@echo "	make pub-r     	  说明：打包release版,这个所有库都编译         示例：make pub-r"
	@echo "	make pub-p     	  说明：只打包                              示例：make pub-p"
	@echo "	make pkg [包名]   说明：编译安装单个包,debug版                示例：make pkg ubt_state"
	@echo "	make pkg-r [包名] 说明：编译安装单个包,release版              示例：make pkg-r ubt_state"
	@echo "	make pkgd [包名]  说明：编译安装单个包和其依赖包,debug版        示例：make pkgd ubt_state"
	@echo "	make pkgd [包名]  说明：编译安装单个包和其依赖包,release版      示例：make pkgd-r ubt_state"
	@echo "	make clean        说明：清理编译和发布环境                    示例：make clean"